package com.bb.Controllers;

import java.util.Map;

import com.bb.pojo.User;
import com.bb.services.impl.UserLoginServiceImpl;
import com.bb.services.impl.UserServiceImpl;
import com.opensymphony.xwork2.ActionContext;

public class UserLoginAction {
	private String u_name;//接收的用户名登录用户名
	private String u_pass;//接收的用户名登录密码
	public String login(){
		/*System.out.println("用户登录");*/
		
		System.out.println("u_name:"+u_name+",u_pass:"+u_pass);
		User chkLogin = new UserLoginServiceImpl().chkLogin(u_name);//根据接收的参数返回该数据
		if(chkLogin != null){
			/*如果查询的结果不为空 就把用户名存到session 里*/
			if(chkLogin.getU_pass().equals(u_pass)){
				Map<String, Object> session = ActionContext.getContext().getSession();
				session.put("username", chkLogin.getU_name());
				System.out.println("登录成功");
				return "loginSuccess";
			}else{
				return "loginError";
			}
		}else{
			return "loginError";
		}
	}
	public String getU_name() {
		return u_name;
	}
	public void setU_name(String u_name) {
		this.u_name = u_name;
	}
	public String getU_pass() {
		return u_pass;
	}
	public void setU_pass(String u_pass) {
		this.u_pass = u_pass;
	}
	
}
